/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package agents;

import java.io.IOException;
import javax.swing.JPanel;
import env.Action;
import env.Orientation;
import env.Enviroment;
import java.awt.Color;
import java.util.Scanner;
import javax.swing.Icon;
import javax.swing.ImageIcon;

/**
 *
 * @author orcas
 */
public class HumanAgentConsole extends Agent {

    static Icon iconNorth = new ImageIcon("images/ShipNorth.gif");
    static Icon iconSouth = new ImageIcon("images/ShipSouth.GIF");
    static Icon iconEast = new ImageIcon("images/ShipEast.GIF");
    static Icon iconWest = new ImageIcon("images/ShipWest.GIF");
    private JPanel frame;

    public HumanAgentConsole(String name, int row, int col, Orientation orientation, Color color) {
        super(name, row, col, orientation, color);
        frame = new JPanel();
    }

    public Action getMove(Enviroment env) {
        int str = -1;
        System.out.print("a/w/d");
        try {
            str = System.in.read();
            switch (str) {
                case 'a':
                    return Action.left;
                case 'w':
                    return Action.fwd;
                case 'd':
                    return Action.right;
                case 'q':
                    System.exit(0);
            }

        } catch (IOException e) {
        }
        return null;
    }

    public Action getMove() {
        System.out.println(this + ": please enter W/A/D");
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.startsWith("W") || s.startsWith("w")) {
            return Action.fwd;
        }
        if (s.startsWith("D") || s.startsWith("d")) {
            return Action.right;
        }
        if (s.startsWith("A") || s.startsWith("a")) {
            return Action.left;
        }
        if (s.equals("q")) {
            System.exit(0);
        }
        return null;

    }

    @Override
    public Icon getIcon() {
        switch (this.getOrientation()) {
            case North:
                return iconNorth;
            case East:
                return iconEast;
            case West:
                return iconWest;
            case South:
                return iconSouth;
        }
        return null;
    }
}
